﻿using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;

namespace HouseOfCards
{
   /// <summary>
   /// Provides a binding list used to display pay-outs in a grid view
   /// </summary>
   public class PayLines
   {
      /// <summary>
      /// Returns a binding list used to display pay-outs in a grid view
      /// </summary>
      /// <param name="gameType"></param>
      /// <returns></returns>
      public BindingList<PayLine> GetPayLines(GameTypes gameType)
      {
         BindingList<PayLine> blpl = new BindingList<PayLine>();

         //default
         blpl.Clear();
         blpl.Add(new PayLine("Royal Flush", 250, 500, 750, 1000, 4000));
         blpl.Add(new PayLine("Straignt Flush", 50, 100, 150, 200, 250));
         blpl.Add(new PayLine("Four of a Kind", 25, 50, 75, 100, 125));
         blpl.Add(new PayLine("Full House", 9, 18, 27, 36, 45));
         blpl.Add(new PayLine("Flush", 6, 12, 18, 24, 30));
         blpl.Add(new PayLine("Straight", 4, 8, 12, 16, 20));
         blpl.Add(new PayLine("Three of a Kind", 3, 6, 9, 12, 15));
         blpl.Add(new PayLine("Two Pair", 2, 4, 6, 8, 10));
         blpl.Add(new PayLine("Jacks or Better", 1, 2, 3, 4, 5));


         if (gameType == GameTypes.JacksOrBetter)
         {
            blpl.Clear();
            blpl.Add(new PayLine("Royal Flush", 250, 500, 750, 1000, 4000));
            blpl.Add(new PayLine("Straignt Flush", 50, 100, 150, 200, 250));
            blpl.Add(new PayLine("Four of a Kind", 25, 50, 75, 100, 125));
            blpl.Add(new PayLine("Full House", 9, 18, 27, 36, 45));
            blpl.Add(new PayLine("Flush", 6, 12, 18, 24, 30));
            blpl.Add(new PayLine("Straight", 4, 8, 12, 16, 20));
            blpl.Add(new PayLine("Three of a Kind", 3, 6, 9, 12, 15));
            blpl.Add(new PayLine("Two Pair", 2, 4, 6, 8, 10));
            blpl.Add(new PayLine("Jacks or Better", 1, 2, 3, 4, 5));
         }

         if (gameType == GameTypes.DoubleBonus)
         {
            blpl.Clear();
            blpl.Add(new PayLine("Royal Flush", 250, 500, 750, 1000, 4000));
            blpl.Add(new PayLine("Straight Flush", 50, 100, 150, 200, 250));
            blpl.Add(new PayLine("Four Aces", 160, 320, 480, 640, 800));
            blpl.Add(new PayLine("Four 2, 3, or 4", 80, 160, 240, 320, 400));
            blpl.Add(new PayLine("Four 5-K", 50, 100, 150, 200, 250));
            blpl.Add(new PayLine("Full House", 10, 20, 30, 40, 50));
            blpl.Add(new PayLine("Flush", 7, 14, 21, 28, 35));
            blpl.Add(new PayLine("Straight", 5, 10, 15, 20, 25));
            blpl.Add(new PayLine("Three of a Kind", 3, 6, 9, 12, 15));
            blpl.Add(new PayLine("Two Pair", 1, 2, 3, 4, 5));
            blpl.Add(new PayLine("Jacks or Better", 1, 2, 3, 4, 5));
         }

         return blpl;
      }
   }

   /// <summary>
   /// Object that represents a pay line with the payout table (collection)
   /// </summary>
   public class PayLine : INotifyPropertyChanged
   {
      public event PropertyChangedEventHandler PropertyChanged;

      public PayLine(string hand, int credit1, int credit2, int credit3, int credit4, int credit5)
      {
         _hand = hand;
         _credit1 = credit1;
         _credit2 = credit2;
         _credit3 = credit3;
         _credit4 = credit4;
         _credit5 = credit5;
      }

      private void NotifyPropertyChanged(string name)
      {
         if (PropertyChanged != null)
            PropertyChanged(this, new PropertyChangedEventArgs(name));
      }

      private string _hand;

      public string Hand
      {
         get { return _hand; }
         set
         {
            _hand = value;
            this.NotifyPropertyChanged("Hand");
         }
      }
      private int _credit1;

      public int Credit1
      {
         get { return _credit1; }
         set
         {
            _credit1 = value;
            this.NotifyPropertyChanged("Credit1");
         }
      }
      private int _credit2;

      public int Credit2
      {
         get { return _credit2; }
         set
         {
            _credit2 = value;
            this.NotifyPropertyChanged("Credit2");
         }
      }
      private int _credit3;

      public int Credit3
      {
         get { return _credit3; }
         set
         {
            _credit3 = value;
            this.NotifyPropertyChanged("Credit3");
         }
      }
      private int _credit4;

      public int Credit4
      {
         get { return _credit4; }
         set
         {
            _credit4 = value;
            this.NotifyPropertyChanged("Credit4");
         }
      }
      private int _credit5;

      public int Credit5
      {
         get { return _credit5; }
         set
         {
            _credit5 = value;
            this.NotifyPropertyChanged("Credit5");
         }
      }
   }
}
